# Maintainer: Levente Polyak <anthraxx[at]archlinux[dot]org>

pkgname=pegtl
_gitcommit=cf639f7f4ee125f68e1ccfba8d99ebc0de57b9fe
pkgver=3.2.7
pkgrel=1
pkgdesc='Parsing Expression Grammar Template Library'
url='https://github.com/taocpp/PEGTL'
arch=('any')
license=('MIT')
makedepends=('git' 'cmake')
source=(${pkgname}::"git+https://github.com/taocpp/PEGTL#commit=${_gitcommit}?signed")
sha512sums=('SKIP')
validpgpkeys=('3AC06334B62566C11A5912FB014C496DEC39EB21') # Daniel Frey <d.frey@gmx.de>

pkgver() {
  cd ${pkgname}
  git describe --tags --always| sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g'
}

build() {
  cd ${pkgname}
  cmake -B build \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DPEGTL_INSTALL_DOC_DIR=share/doc/${pkgname} \
    -DPEGTL_INSTALL_CMAKE_DIR=lib/cmake/${pkgname} \
    -DPEGTL_BUILD_EXAMPLES=OFF \
    -DPEGTL_BUILD_TESTS=ON
  make -C build VERRBOSE=1
}

check() {
  cd ${pkgname}/build
  ctest
}

package() {
  cd ${pkgname}
  make -C build DESTDIR="${pkgdir}" install
  install -Dpm 644 README.md -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -Dpm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}

# vim: ts=2 sw=2 et:
